<?php
/**
 * Note: *
 * Date: 2020/4/15
 */
namespace App\Observers;

use App\Services\GameNotifyService;
use Illuminate\Database\Eloquent\Model;

class GameServerTableObserver
{
    /**
     * @param Model $model
     */
    public function created(Model $model)
    {
        GameNotifyService::modelEvent(
            $model->getConnection()->getTablePrefix().$model->getTable(),
            $model->getKey(),
            GameNotifyService::MODEL_EVENT_CREATED
        );
    }

    /**
     * @param Model $model
     */
    public function updated(Model $model)
    {
        GameNotifyService::modelEvent(
            $model->getConnection()->getTablePrefix().$model->getTable(),
            $model->getKey(),
            GameNotifyService::MODEL_EVENT_UPDATED
        );
    }

    /**
     * @param Model $model
     */
    public function deleted(Model $model)
    {
        GameNotifyService::modelEvent(
            $model->getConnection()->getTablePrefix().$model->getTable(),
            $model->getKey(),
            GameNotifyService::MODEL_EVENT_DELETED
        );
    }
}
